CXX      = g++
CXXFLAGS =   
LINK     = g++
LFLAGS   = -shared -ldl -lpthread

COPY     = cp -f
COPY_FILE= $(COPY)
COPY_DIR = $(COPY) -r
INSTALL_FILE= $(COPY_FILE)
INSTALL_DIR = $(COPY_DIR)
RELEASE_DIR = ../release
DEL_FILE = rm -f
DEL_DIR = -rm -rf
CREATE_DIR = -mkdir
SYMLINK  = ln -sf
MOVE     = mv -f
CHK_DIR_EXISTS= test -d
MKDIR    = mkdir -p

####### Output directory

OBJECTS_DIR = .obj/

####### Files

HEADERS = Lowlayer.hpp \
		Detailingflea.hpp \
		Chainflea.hpp \
		Normalflea.hpp \
		Udpflea.hpp \
		Dispatcher.hpp
SOURCES = Lowlayer.cpp \
		Detailingflea.cpp \
		Chainflea.cpp \
		Udpflea.cpp \
		Normalflea.cpp \
		Dispatcher.cpp \
		Mainlib.cpp 
		
OBJECTS = $(OBJECTS_DIR)Lowlayer.o \
		$(OBJECTS_DIR)Detailingflea.o \
		$(OBJECTS_DIR)Normalflea.o \
		$(OBJECTS_DIR)Chainflea.o \
		$(OBJECTS_DIR)Udpflea.o \
		$(OBJECTS_DIR)Dispatcher.o \
		$(OBJECTS_DIR)Mainlib.o 
		 




TARGET   = libflealib.so.0.9.1
#TARGETD	= libflealib.so.1.0.0
#TARGET0	= libflealib.so
#TARGET1	= libflealib.so.1
#TARGET2	= libflealib.so.1.0

first: all
####### Implicit rules
.SUFFIXES: .c .o .cpp .cc .cxx .C

.cpp.o:
	$(CXX) -c $(CXXFLAGS)  -o $@ $<

.cc.o:
	$(CXX) -c $(CXXFLAGS)  -o $@ $<

.cxx.o:
	$(CXX) -c $(CXXFLAGS)  -o $@ $<

.C.o:
	$(CXX) -c $(CXXFLAGS)  -o $@ $<

.c.o:
	$(CC) -c $(CXXFLAGS)  -o $@ $<

####### Build rules
prepare:
	$(DEL_DIR) $(OBJECTS_DIR)
	$(CREATE_DIR) $(OBJECTS_DIR)
all: Makefile  prepare $(TARGET)
$(TARGET):   $(OBJECTS) 
	-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)
	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) 
#	-ln -s $(TARGET) $(TARGET0)
#	-ln -s $(TARGET) $(TARGET1)
#	-ln -s $(TARGET) $(TARGET2)



clean:
	-$(DEL_FILE) $(OBJECTS)
	-$(DEL_FILE) *~ core *.core
	-$(DEL_FILE) $(TARGET)
	-$(DEL_FILE) $(TARGET0)
	-$(DEL_FILE) $(TARGET1)
	-$(DEL_FILE) $(TARGET2)


####### Compile
$(OBJECTS_DIR)Lowlayer.o: Lowlayer.cpp Lowlayer.hpp
	$(CXX) -c $(CXXFLAGS)  -o $(OBJECTS_DIR)Lowlayer.o Lowlayer.cpp
 
$(OBJECTS_DIR)Chainflea.o: Chainflea.cpp Chainflea.hpp \
		Lowlayer.hpp
	$(CXX) -c $(CXXFLAGS)  -o $(OBJECTS_DIR)Chainflea.o Chainflea.cpp

$(OBJECTS_DIR)Detailingflea.o: Detailingflea.cpp Detailingflea.hpp \
		Lowlayer.hpp
	$(CXX) -c $(CXXFLAGS)  -o $(OBJECTS_DIR)Detailingflea.o Detailingflea.cpp

$(OBJECTS_DIR)Normalflea.o: Normalflea.cpp Normalflea.hpp \
		Lowlayer.hpp
	$(CXX) -c $(CXXFLAGS)  -o $(OBJECTS_DIR)Normalflea.o Normalflea.cpp

$(OBJECTS_DIR)Udpflea.o: Udpflea.cpp Udpflea.hpp \
		Lowlayer.hpp
	$(CXX) -c $(CXXFLAGS)  -o $(OBJECTS_DIR)Udpflea.o Udpflea.cpp

$(OBJECTS_DIR)Dispatcher.o: Dispatcher.cpp Dispatcher.hpp \
		Lowlayer.hpp \
		Normalflea.hpp \
		Detailingflea.hpp \
		Chainflea.hpp \
		Udpflea.hpp
	$(CXX) -c $(CXXFLAGS)  -o $(OBJECTS_DIR)Dispatcher.o Dispatcher.cpp


$(OBJECTS_DIR)Mainlib.o: Mainlib.cpp Dispatcher.hpp \
		Lowlayer.hpp \
		Normalflea.hpp \
		Detailingflea.hpp \
		Chainflea.hpp \
		Udpflea.hpp
	$(CXX) -c $(CXXFLAGS)  -o $(OBJECTS_DIR)Mainlib.o Mainlib.cpp

####### Install

install:  

uninstall:  

